import React, { Component } from 'react'
import Home from './Home'
import ThemeContext from './context/theme-context'
import UserContext from './context/user-context'
// 1.创建上下文
// const ThemeContext = React.createContext();
export class App extends Component {
  constructor() {
    super()
    this.state = {
      info: {
        name: '张三',
        age: 18

      }
    }
  }
  render () {
    const { info } = this.state
    return (
      <div>
        APP
        {/* 2.使用provider 报告需要共享数据的组件 */}
        {/* <ThemeContext.Provider value={{ color: 'red', size: 18 }}>
          <Home {...info} />
        </ThemeContext.Provider> */}
        <UserContext.Provider value={{ userName: 'jack' }}>
          <ThemeContext.Provider value={{ color: 'red', size: 18 }}>
            <Home {...info} />
          </ThemeContext.Provider>
        </UserContext.Provider>
      </div>
    )
  }
}

export default App